factory method design pattern in c